﻿using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Zeus.Classes;

namespace Zeus.UserControls
{
    public partial class AddNewItem_ChildWindow : ChildWindow
    {
        public AddNewItem_ChildWindow()
        {
            InitializeComponent();
            List<InfoItems> Objlist_1 = FillNewItemChildWindow.AddImageItems();
            for (int i = 0; i < Objlist_1.Count; i++)
            {
                ListBox_Items.Items.Add(Objlist_1[i]);
            }
            Itemcategories.SelectedItem = Itemcategories.Items[0];

        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {

            ListBoxItem S = (ListBoxItem)Itemcategories.SelectedItem;
            InfoItems imageOfItems = (InfoItems)ListBox_Items.SelectedItem;
            switch (S.Content.ToString())
            {
                case "Images":
                    {
                        AddImage(imageOfItems.Path,Filename.Text);
                        break;
                    }
                case "Meshes":
                    {
                        break;
                    }
                case "Sounds":
                    {
                        break;
                    }
                case "Videos":
                    {
                        break;
                    }
                case "Data":
                    {
                        if (imageOfItems.Name == "Class File")
                            Project.AddClass(Filename.Text);
                        else
                            Project.AddText(Filename.Text);
                        break;
                    }
            }

            
            this.DialogResult = true;
        }
        public void AddImage(string path,string name)
        {
            
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void ImageListBoxItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListBox_Items.Items.Clear();
            List<InfoItems> Objlist_1 = FillNewItemChildWindow.AddImageItems();
            for (int i = 0; i < Objlist_1.Count; i++)
            {
                ListBox_Items.Items.Add(Objlist_1[i]);
            }
            ListBox_Items.SelectedItem = ListBox_Items.Items[0];
            Filename.Text = Objlist_1[0].Name + ".jpg";
        }

        private void MeshListBoxItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListBox_Items.Items.Clear();
            List<InfoItems> Objlist_2 = new List<InfoItems>();
            Objlist_2 = FillNewItemChildWindow.AddMeshItems();
            for (int i = 0; i < Objlist_2.Count; i++)
            {
                ListBox_Items.Items.Add(Objlist_2[i]);
            }
            ListBox_Items.SelectedItem = ListBox_Items.Items[0];
            Filename.Text = Objlist_2[0].Name + ".x";
        }

        private void SoundListBoxItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListBox_Items.Items.Clear();
            List<InfoItems> Objlist_3 = new List<InfoItems>();
            Objlist_3 = FillNewItemChildWindow.AddSoundItems();
            for (int i = 0; i < Objlist_3.Count; i++)
            {
                ListBox_Items.Items.Add(Objlist_3[i]);
            }
            ListBox_Items.SelectedItem = ListBox_Items.Items[0];
            Filename.Text = Objlist_3[0].Name + ".wav";
        }

        private void VideoListBoxItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListBox_Items.Items.Clear();
            List<InfoItems> Objlist_4 = new List<InfoItems>();
            Objlist_4 = FillNewItemChildWindow.AddVideoItems();
            for (int i = 0; i < Objlist_4.Count; i++)
            {
                ListBox_Items.Items.Add(Objlist_4[i]);
            }
            ListBox_Items.SelectedItem = ListBox_Items.Items[0];
            Filename.Text =Objlist_4[0].Name + ".wmv";
        }

        private void DataListBoxItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListBox_Items.Items.Clear();
            List<InfoItems> Objlist_4 = new List<InfoItems>();
            Objlist_4 = FillNewItemChildWindow.AddTextItems();
            for (int i = 0; i < Objlist_4.Count; i++)
            {
                ListBox_Items.Items.Add(Objlist_4[i]);
            }
            ListBox_Items.SelectedItem = ListBox_Items.Items[0];
            Filename.Text = Objlist_4[0].Name + ".cs";
        }

        private void ListBox_Items_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListBoxItem S = (ListBoxItem)Itemcategories.SelectedItem;
            InfoItems imageOfItems = (InfoItems)ListBox_Items.SelectedItem;
            switch (S.Content.ToString())
            {
                case "Images":
                    {
                        Filename.Text = imageOfItems.Name + ".jpg";
                        break;
                    }
                case "Meshes":
                    {
                        Filename.Text = imageOfItems.Name + ".x";
                        break;
                    }
                case "Sounds":
                    {
                        Filename.Text = imageOfItems.Name + ".wav";
                        break;
                    }
                case "Videos":
                    {
                        Filename.Text = imageOfItems.Name + ".wmv";
                        break;
                    }
                case "Data":
                    {
                        if (imageOfItems.Name == "Class File")
                        {
                            Filename.Text = "Class1.cs";
                        }
                        else
                        {
                            Filename.Text = "Text1.txt";
                        }
                        
                        break;
                    }
            }
        }
    }
}

